<!--
 * @Author: your name
 * @Date: 2020-12-03 17:46:12
 * @LastEditTime: 2020-12-08 14:13:57
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\inventory\record.vue
-->
<!--
 * @Author: your name
 * @Date: 2020-12-03 15:52:30
 * @LastEditTime: 2020-12-03 17:19:05
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \solaxcloud\src\views\inventory\inventory_push.vue
-->
<template>
    <div>
        <el-dialog
        :title="$t('battery.saleStatistics.batteryInfo')"
        :visible="apiVisible"
        width="70%"
        @close="()=>{$store.commit('setApiVisible',false)}"
        :close-on-click-modal='true'
        >   
            <div class="record-mian-box">
                <baseTable v-loading="loading"  row-key='sid' :data="dataRows" border  stripe :column='column' :select='false' @selection-change="handleSelectionChange($event)">
                    <template #numberR='{data}'>
                        {{returnNumber(data)}}
                    </template>
                    <template #status='{data}'>
                        {{returnStatus(data)}}
                    </template>
                    <template #storeType='{data}'>
                        {{returnType(data)}}
                    </template>
                </baseTable>
                <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="current"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
                </el-pagination>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import baseTable from '../../../components/common/baseTable'
export default {
    components: {
        baseTable
    },
    props: {
        returnStatusNumber:{
            type:Boolean,
        },
        editRow:{
            type:Object,
            default:()=>{return {}}
        }
    },
    data() {
        return {
            pickerOptions:{ //禁用今天之后的时间
                disabledDate(time) {
                    return time.getTime() > Date.now()
                }
            },
            startTime:'',
            endTime:'',
            loading:false,
            dataRows:[],
            column:[{
                title: this.$t('invoice.batterySN'),
                value: 'batterySN',
                slot: 'batterySN',
            },
            {
                title: this.$t('warranty.newAddData'),
                value: 'formatInstallTime',
                slot: 'formatInstallTime',
            },
            {
                title: this.$t('warranty.batteryMsg.warrantyTiem'),
                value: 'period',
                slot: 'period',
            }],
            size:10,
            current:1,
            total:1
        };
    },
    computed: {
        apiVisible(){
            return this.$store.state.sysStore.apiVisible
        },
        userType(){
            return localStorage.getItem('userType')
        },
        lan(){
            return localStorage.getItem('lan')
        },
    },
    watch: {
        apiVisible:{
            handler(nv,ov){
                if(nv){
                    this.current = 1
                    this.size = 10
                    this.crmbatteryqualityGetPage()
                }
            }
        }
    },
    created() {

    },
    mounted() {
    },
    methods: {
        async crmbatteryqualityGetPage(){
            this.loading = true
            let res = await this.API.crmbatteryqualityGetPage({
                size:this.size,
                current:this.current,
                inverterSn:this.editRow.inverterSn
            })
            this.total = res.object.total
            this.dataRows = res.object.rows || []
            this.loading = false
        },
        query(){
            this.current = 1
            this.wmspartsrecordsGetPage()
        },
        handleSizeChange(val) {
          this.size = val
          this.current = 1
          this.wmsstockGetPage()
        },
        handleCurrentChange(val) { 
          this.current = val
          this.wmsstockGetPage()
        },
    },
};
</script>

<style  lang="less" scoped>
.record-mian-box{
    padding-bottom:50px; 
}
</style>
